﻿using ManagementClinic.App.Common;
using ManagementClinic.App.View;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace ManagementClinic.App.ViewModel
{
   public class TabViewModel : ViewModelBase
    {
        private ICommand closeCommand;

        public ICommand CloseCommand
        {
            get
            {
                if (closeCommand == null)
                {
                    closeCommand = new CommandBase(i => this.DeleteTab(), null);
                }
                return closeCommand;
            }
        }

        public void DeleteTab()
        {
            var total = TabControlMain.TabControl.Items.Count;
            var index = TabControlMain.TabControl.SelectedIndex;
            if(total>1)
                TabControlMain.TabControl.Items.RemoveAt(index);
        } 
    }
}
